<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>创建一个新的日期。</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongodate.html">MongoDate</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodate.tostring.html">MongoDate::__toString</a></div>
 <div class="up"><a href="class.mongodate.html">MongoDate</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mongodate.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDate::__construct</h1>
  <p class="verinfo">(PECL mongo &gt;= 0.8.1)</p><p class="refpurpose"><span class="refname">MongoDate::__construct</span> &mdash; <span class="dc-title">创建一个新的日期。</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodate.construct-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>MongoDate::__construct</strong></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$sec</code><span class="initializer"> = time()</span></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$usec</code><span class="initializer"> = 0</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   创建一个新的日期。如果没有指定参数，将会使用当前的时间。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodate.construct-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>

      <em><code class="parameter">sec</code></em>
     </dt>

     <dd>

      <p class="para">
       自 1970 年 1 月 1 日以来的秒数。
      </p>
     </dd>

         
    
     <dt>

      <em><code class="parameter">usec</code></em>
     </dt>

     <dd>

      <p class="para">
       微秒。
      </p>
     </dd>

         
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodate.construct-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回该新的时间。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mongodate.construct-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1466">
   <p><strong>Example #1 <span class="function"><strong>MongoDate::__construct()</strong></span> 例子</strong></p>
   <div class="example-contents"><p>这个例子演示了用当前时间创建一个新的日期以及给定时间的新日期。</p></div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$d&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDate</span><span style="color: #007700">();<br />echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$d</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$d&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDate</span><span style="color: #007700">(</span><span style="color: #0000BB">1234567890</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$d</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$d&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDate</span><span style="color: #007700">(</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"2009-05-01&nbsp;00:00:01"</span><span style="color: #007700">));<br />echo&nbsp;</span><span style="color: #DD0000">"</span><span style="color: #0000BB">$d</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
0.23660600 1235685067
0.00000000 1234567890
0.00000000 1241150401
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-mongodate.construct-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="mongodate.tostring.html" class="methodname" rel="rdfs-seeAlso">MongoDate::__toString()</a> - 返回该日期的字符串形式的表达</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongodate.html">MongoDate</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mongodate.tostring.html">MongoDate::__toString</a></div>
 <div class="up"><a href="class.mongodate.html">MongoDate</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
